/**
 * 
 */
package org.cuatrovientos.collectionexercice2;

import java.util.Collections;
import java.util.Random;
import java.util.Vector;

	/**
	 * 
	 * @author daniel_ancin
	 * vector de la clase carta
	 */
	public class Deck {
		private Vector<Card> cards;
				
		 public void Shuffle(){   // Abre metodo barajar
			 
			 Random random = new Random(); 
			 Card tempCard;
			 int randomIndex=0;
		 
		 for ( int i = 0; i <cards.size(); i++ ){ // Abre for
			  randomIndex= random.nextInt(cards.size());
			  tempCard = cards.get(i);
			  cards.set(i, cards.get( randomIndex));
			  cards.set(randomIndex,tempCard);
			 
		 }  // Cierra for
	} 
	
	 
		 
	/**
	 * default constructor
	 */
	
	public Deck() {
		cards= new Vector<Card>();
		loadDeck();
		
	}
	
	/**
	 * load card into deck
	 */
	private void loadDeck(){
		String [] suits = {"Spades", "Clubs","Hearts","Diamonds "};
		String [] names = {"2", "3","4","5","6","7","8","9","10","J","Q"};
		
		int value = 2;
		
		for (int i=0; i<suits.length;i++){
			for (int j=0; j<names.length;j++){
			//cards.add(new Card("2","Spades",2));
				
			cards.add(new Card(names[j],suits[i],value));
				value++;
			
			}
		value=2;
		
		}
	
	}
	/**
	 * Shuffles the Deck
	 */
	public void shuffle(){
		Collections.shuffle(cards);
		
	}
	/**
	 * Show deck contents
	 */
	public String toString(){
		return cards.toString();
		
		}
	
	/**
	 * 	gets a card fron the deck
	 * @param i car index
	 * @return a card
	 */
	public Card getCard(int i){
		return cards.get(i);
	}
	}
	